home *** CD-ROM | disk | FTP | other *** search
/ Nothing but GIFs AGA / Nothing But GIFs.iso / giftoiff.lha / GIFtoIFF.doc < prev    next >
Text File  |  1995-11-15  |  9KB  |  201 lines

  1.  
  2.         GIFtoIFF Version 2.0
  3.  
  4. I.    Introduction
  5.  
  6.         This set of programs was written to satisfy my curiousity. 
  7.         They were uploaded to a local BBS to gain more download 
  8.         time and now they've come back to haunt me. I thought the BBS 
  9.         would delete it.
  10.  
  11.         The first version was quickly written and had a lot of bugs. 
  12.         I've since stomped on all of the ones I know about. I've 
  13.         re-written most of the code to speed it up considerably and 
  14.         I've added new features and programs, such as EHB, GIFhdr 
  15.         and TmpX.  Read the file Release2.0 for more details.
  16.  
  17.         These programs convert GIF files into many of the Amiga IFF
  18.         formats. They are mainly for converting GIF files that have
  19.         more colors than the Amiga can currently handle, but they 
  20.         will convert the others as well. The programs themselves aren't
  21.         real user friendly, but do allow themselves to be run in scripts.
  22.         I usually set up a script and let my Amiga convert a bunch of
  23.         images while I'm doing something else. See the section on Convert
  24.         farther down. 
  25.  
  26.         These programs may and should be freely distributed. No money
  27.         need be sent. I will try to support them the best I can, but 
  28.         work's been taking most of my time as of late.
  29.  
  30.         If new modes for the Amiga are invented, become stable and 
  31.         viewers for those new modes become widely available, I'll 
  32.         add them to my programs. I've heard of a couple new modes 
  33.         that use copper lists to change color registers on a per 
  34.         line basis. I'd like to hear more about those modes.  
  35.         
  36. II.    File Summary
  37.  
  38.         Below is a list of the files included in this package and briefly
  39.         what they do. The Usage of each of these files can be obtained
  40.         by just typing the file name. The exception is the script file
  41.         Convert and its usage is at the end of this section.
  42.         The stack should be set to 8000 or 16000 for larger files.
  43.  
  44.  
  45.             GIFhdr     Gives information about a GIF file
  46.      
  47.             GIFtoTMP   Converts GIF files into TMP files.
  48.                            Exits with Warn if file is interlaced.
  49.                            Look at Convert to see how it's used.
  50.      
  51.             Unlace     Will unlace a TMP file. Use only if
  52.                            GIFtoTMP indicates the file as Interlaced or
  53.                            if you like scrambled pictures.
  54.      
  55.             TMPtoIFF   Converts TMP files into IFF files
  56.  
  57.             TmpX        Extracts a section of a TMP file. Useful for
  58.                             breaking up those 640x400x256 files into a 
  59.                             384x400 file. Usually you don't miss too much. 
  60.      
  61.             convert     A CLI script file I use to convert the images
  62.                             from GIF to IFF. 
  63.      
  64.                    convert giffilepath giffilename [opt1 opt2] [NOTMP]
  65.  
  66.                    giffilepath   is the path to the directory in which 
  67.                                  the gif file is located.
  68.  
  69.                    giffile       is the name of the file to convert 
  70.                                  (with or without the .gif extension). 
  71.                                  Convert looks for both.
  72.  
  73.                    opt1,opt2     are options which get passed to tmptoiff.
  74.  
  75.                    NOTMP         must be the third option(for now) and 
  76.                                  tells Convert to delete <giffile>.tmp 
  77.                                  when Convert is done with it.
  78.  
  79.                 Notes on Convert:
  80.  
  81.               -   G2I: needs to be assigned to the directory that 
  82.                   contains GIFtoTMP,Unlace and TMPtoIFF.
  83.  
  84.               -   The final file is called <giffile>.pic and is placed 
  85.                   in the local directory.
  86.  
  87.               -   Intermediate files <giffile>.ltmp and <giffile>.tmp 
  88.                   are used by Unlace and GIFtoTMP, respectively. These 
  89.                   will OVERWRITE any existing files by that name.
  90.  
  91.               -   If the NOTMP option is not specified, <giffile>.tmp 
  92.                   will still exist at the end of the script. 
  93.  
  94.               -   If convert finds <giffile>.tmp to exist at the start, 
  95.                   it will jump directly to TMPtoIFF, bypassing GIFtoTMP 
  96.                   and Unlace. I find it useful. 
  97.  
  98.  
  99. III.    TMP File Format
  100.  
  101.         The TMP File Format is yet another format. At the time I originally
  102.         wrote this, I wasn't familiar with FBM or PBMPlus formats or I 
  103.         would've used one of those. But would I have been able to pass
  104.         this along with those formats? What follows is a brief description 
  105.         of the format.
  106.      
  107.            struct TMPFILE
  108.            {
  109.             SHORT ImageWidth,ImageHeight,NoOfColorRegisters;
  110.             Struct COLORREGISTER ColorRegisters[NoOfColorRegisters];
  111.             UBYTE Image[ImageHeight][ImageWidth];
  112.            }
  113.      
  114.            where struct COLORREGISTER is
  115.      
  116.            struct COLORREGISTER
  117.            {
  118.             UBYTE red,green,blue;
  119.            }
  120.  
  121.          ** Note that the picture is Image[y][x] not Image[x][y] **
  122.      
  123.      
  124.         The Image array indexes into the ColorRegisters array, which holds
  125.         the actual color values. For example-The red component of a pixel
  126.         (x,y) is given by the value  of  ColorRegisters[Image[y][x]].red.
  127.         A value of 255 is all the  way  on.  A  value of 0 is all the way
  128.         off. Since the Amiga can only display  4 bits per color component
  129.         the following equation should be used:
  130.      
  131.         temp=ColorRegisters[Image[y][x]].red
  132.         RedComponent = (tmp>>4) & 0x0f; 
  133.      
  134.         And'ing the value with 0x0f  probably  isn't  necessary but helps
  135.         conceptually.
  136.      
  137. III.    Quantization Algorithms Used
  138.      
  139.         The following briefly describes the three current choices
  140.         the program TMPtoIFF gives for selecting the 'best' y number
  141.         of colors from the original ones. 
  142.      
  143.         Popularity-Chooses the most used colors from the histogram.
  144.      
  145.         Median Cut-Thinks of the colors as points in three dimensional
  146.                    space (Red,Green,Blue) and draws a box that
  147.                    encloses all points. The program then divides that
  148.                    box into two boxes with an equal number of colors in
  149.                    each side. (A pure white screen would only have one
  150.                    color-even though that color is used in thousands of 
  151.                    pixels)
  152.                    The boxes are continuously divided along their
  153.                    longest axis until there are as many boxes as the
  154.                    number of colors that you want. Then the colors in
  155.                    each box are averaged and those values are used for 
  156.                    the final color map.
  157.      
  158.        Weighted Median Cut-I modified the above algorithm so that as
  159.                   it's dividing each box along the longest axis, it
  160.                   tries to put an equal number of pixels in each side
  161.                   (which of course is impossible to do exactly)
  162.                   This produces averaged colors closer to the majority
  163.                   colors(as in Popularity), but also provides the variety 
  164.                   that the Median Cut algorithm does.
  165.      
  166.      After one of  the  above  algorithms  is  run,  each pixel in the
  167.      original image is replaced with  the  closest  value in the final
  168.      color map. 
  169.      If an EHB(Extra Half Brite) image is requested, one of the above 
  170.      methods is used to come up with 32 colors. Each of these colors is 
  171.      then used to produce 32 more colors by dividing each component(red,
  172.      green and blue) by two. This gives a final color map of 64 colors.
  173.      If a HAM image is  requested,  the program uses one of the above 
  174.      algorithms to produce the 16 base colors used in HAM mode.
  175.      
  176.      Extra Half Brite support is experimental at best. I tried a couple
  177.      quick methods to shift color selection to the brighter colors, since
  178.      the second set of 32 colors is just a darker version of the first
  179.      set. I also look through the first set to weed out dark colors that
  180.      will be produced by creating the second set.
  181.      When it comes to images, EHB isn't very useful since HAM does a better
  182.      job with the same amount of memory(of course there's exceptions, but
  183.      they probably have to be thought out and won't occur naturally).
  184.  
  185.  
  186.  
  187. IV  Closing Monologue
  188.  
  189.      Thanks for using this and I hope it proves to be useful.
  190.      Any questions, comments or information that I might find useful
  191.      please send to the following address.
  192.  
  193.  
  194.                           Mark Podlipec
  195.                           27-7 Yorkshire Terrace
  196.                           Shrewsbury  MA  01545
  197.  
  198.       I used to read comp.sys.amiga regularly until our feed got yanked.
  199.       Hopefully, it'll be back soon.
  200.  
  201.